<template>
	<view>
		<view class="form">
			<u--form labelPosition="left" labelWidth="100" :model="model1" :rules="rules" ref="uForm">
	
				<u-form-item label="姓名" prop="selectAddress.name" borderBottom>
					<u--input v-model="selectAddress.name" border="none" placeholder="selectAddress.name"></u--input>
				</u-form-item>
	
				<u-form-item label="手机号" prop="Info.mobile" borderBottom>
					<u--input v-model="selectAddress.mobile" border="none" placeholder="请输入联系人手机号"></u--input>
				</u-form-item>
	
				<u-form-item label="性别" prop="Info.sex" borderBottom>
					<u-radio-group v-model="selectAddress.gander">
						<u-radio v-for="(item, index) in ['男','女']" :key="index" :label="item" :name="item" @change="Info.gander=item">
						</u-radio>
					</u-radio-group>
				</u-form-item>
	
				<u-form-item label="地址" prop="Info.address" borderBottom>
					<u--input v-model="selectAddress.address" border="none" placeholder="请输入收货地址"></u--input>
				</u-form-item>
	
				<u-form-item label="门牌号" prop="Info.house_number" borderBottom>
					<u--input v-model="selectAddress.house_number" border="none" placeholder="例:14号楼402室"></u--input>
				</u-form-item>
	
	
				<u-form-item label="设为默认地址" prop="Info.is_default" borderBottom>
					<u-switch v-model="selectAddress.is_default" size="28"></u-switch>
				</u-form-item>
				
			</u--form>
			
		</view>
	
		<view class="save">
			<u-button type="error" shape="circle" @click="updateAddress(selectAddress)">确认修改</u-button>
		</view>
	</view>
</template>

<script>
	const CloudAddress=uniCloud.importObject("address")
	export default {
		data() {
			return {
				user_id:"",
				address_id:"",
				selectAddress:"",
			};
		},
		onLoad(e){
			console.log(e);
			this.address_id=e.address_id;
			this.getAddressBYID(this.address_id)
		},
		methods:{
			getAddressBYID(address_id){
				CloudAddress.getAddressBYID(address_id).then(res=>{
					console.log(res.data[0]);
					this.selectAddress=res.data[0];
					
				})
			},
			updateAddress(selectAddress){
				CloudAddress.updateAddressBYID(selectAddress).then(res=>{
					console.log(res);
					uni.navigateBack()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.form {
		width: 100%;
		padding: 0 20rpx;
	}

	.item4 {
		display: flex;
		justify-content: space-between;
	}

	.save {
		width: 100%;
		position: fixed;
		bottom: var(--window-bottom, 0);
		box-sizing: content-box;
	}
</style>
